package com.task.core.domain.info;

import java.util.List;

import com.task.common.enums.MissionSendHistoryDisplayEnum;
import com.task.core.dto.response.MissionHistoryDetailResposeDTO;
import org.springframework.util.CollectionUtils;

import lombok.Data;

/**
 * @author 迪迦.
 * @date 2025/1/15 16:05
 */
@Data
public class MissionOfSendHistoryInfo {

  private Integer allRequestCount;

  private Integer successCount;

  private Integer failedCount;

  public MissionOfSendHistoryInfo(List<MissionHistoryDetailResposeDTO> missionSendHistoryInfos) {
    if (!CollectionUtils.isEmpty(missionSendHistoryInfos)) {
      this.allRequestCount = missionSendHistoryInfos.size();
      this.successCount = (int) missionSendHistoryInfos.stream().filter(f -> f.getCompleteStatus()).count();
      this.failedCount = (int)missionSendHistoryInfos.stream().filter(f -> (f.getCompleteStatus() == false && f.getDisplayFlag() == MissionSendHistoryDisplayEnum.SHOW.getDisplay())).count();
    }else {
      this.allRequestCount = 0;
      this.successCount = 0;
      this.failedCount = 0;
    }
  }

  public MissionOfSendHistoryInfo() {
  }
}
